package com.dumplings;

public class Dumplings {
    public static int num = 25;

    public static void main(String[] args) {
        Person p1 = new Person("大壮");
        Person p2 = new Person("小明");
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    if (num <= 0) {
                        break;
                    }
                    p2.eat();
                    num--;
                    System.out.println("剩余饺子" + num);
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    if (num <= 0) {
                        break;
                    }
                    p1.eat();
                    num--;
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("剩余饺子" + num);
                }
            }
        }).start();




    }
}
